import { configureStore, combineReducers } from '@reduxjs/toolkit'
import { persistStore, persistReducer } from 'redux-persist'
import { useSelector as useReduxSelector, useDispatch as useReduxDispatch } from 'react-redux'
import storage from 'redux-persist/lib/storage'
// import reduxThunk from "redux-thunk";
// import reduxPromise from "redux-promise";
import auth from './modules/auth'
import global from './modules/global'
import tabs from './modules/tabs'
import menu from './modules/menu'

const reducer = combineReducers({
  auth,
  global,
  tabs,
  menu
})

const persistConfig = {
  key: 'redux-state',
  storage: storage,
}
export const store = configureStore({
  reducer: persistReducer(persistConfig, reducer),
  // middleware: [reduxThunk,reduxPromise]
})
export const persistor = persistStore(store)
export const useSelector = useReduxSelector
export const useDispatch = () => useReduxDispatch()
